﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KPIS.GERP.OMVC.Classes;

namespace KPIS.GERP.OMVC.Controllers
{
    public class IssueController : Controller
    {
        private SsMng ssMng = new SsMng();

        public ActionResult NotLogin()
        {
            string previousUrl = Request["currenturl"];
            string loginUrl = ssMng.PortNumber == 80 ? Common.EssLoginUrl : Common.InternalLoginUrl;
            string serverUrl = ssMng.ServerName;
            const int delaySecRedirect = 2;


            if (!String.IsNullOrEmpty(previousUrl) && previousUrl != serverUrl &&
                previousUrl != serverUrl + "/" && !previousUrl.Contains("Issue"))
            {
                ViewData["url"] = loginUrl + "?lasturl=" + HttpUtility.UrlEncode(Request["currenturl"]);
            }
            else
            {
                ViewData["url"] = loginUrl;
            }
            ViewData["seconds"] = delaySecRedirect;
            ViewData["interval"] = "1000";

            return View();
        }

        public ActionResult PageNotFound()
        {
            // do some log
            return View();
        }
    }
}
